﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HCDV;
using HCDV.HCSP;
using hrainwebbase.basecs;

namespace hrainwebbase
{
    public partial class index : PageBase
    {
        public string htmlinfo = "无可用菜单， 请联系管理员";
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                PageBegin("index",false);
                string menudl = "<dl id=\"menu-system\">" +
                 "<dt><i class=\"Hui-iconfont\">{0}</i> {1}<i class=\"Hui-iconfont menu_dropdown-arrow\">&#xe6d5;</i></dt>" +
                 "<dd>" +
                     "<ul>{2}</ul>" +
                 "</dd>" +
             "</dl>";
                string menuul = "<li><a _href=\"{0}\" href=\"javascript:void(0)\">{1}</a></li>";
                if (1 == 1 )
                {


                    DataTable dt;
                    using (HCDV.HCSP.dbsimple db = new HCDV.HCSP.dbsimple())
                    {
                        dt = db.hcGetMenu(Session["EmpID"].ToString());
                    }
                    //图标  系统管理  &#xe62e;  fshowimg
                    if (dt.Rows.Count > 0)
                    {
                        htmlinfo = "";
                        string addmenuul = "";
                        string id = "null";
                        DataRow drmain = null;
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["c_menuid"].ToString().StartsWith(id))
                            {
                                addmenuul += string.Format(menuul, dr["c_url"].ToString(), dr["c_menuname"].ToString());
                            }
                            else
                            {
                                if (drmain != null)
                                {
                                    htmlinfo += string.Format(menudl, drmain["fshowimg"].ToString(), drmain["c_menuname"].ToString(), addmenuul);
                                    drmain = null;
                                }
                                //新的分类
                                addmenuul = "";
                                id = dr["c_menuid"].ToString();
                                drmain = dr;
                            }
                        }
                        if (drmain != null)
                        {
                            htmlinfo += string.Format(menudl, drmain["fshowimg"].ToString(), drmain["c_menuname"].ToString(), addmenuul);
                            drmain = null;
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                LogHelper.LogError(ee.Message, ee);
                Response.Redirect("/", false); 
                
            }



        }
    }
}